#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include "..//include//createvfs.h"
#include "..//include//hash.h"


int mount_hash(char label[],char filename_g[])
{
	int i;
	struct header head;
	int len_name, len_path;

	FILE *fp_h;
	fp_h = fopen(filename_g, "rb+");
	//printf("\n\n in hash mount function\n filename : %s",filename);
	initialise();			// initializes hash headers to NULL
	if (fp_h == NULL) {
			printf("mountvfs_FAILURE %s\n",ERR_VFS_MOUNT_02);
		return 0;
	}
	else 
	{
		fread(&head, sizeof(struct header), 1, fp_h);
		for(i=0;i<TOTAL_DESC;i++){
			
			len_name=strlen(head.fd_arr[i].name);
			len_path=strlen(head.fd_arr[i].path);
			if(isalpha(head.fd_arr[i].name[0]))
			hashfile(head.fd_arr[i].name,head.fd_arr[i].path);
		}
	fclose(fp_h);
	}
	
	//printf("Mounted hash!!\n");
	return 1;
}

void initialise() {
int i;
for(i=0;i<27;i++)
head[i]=NULL;
}

